package com.ruoyi.web.controller.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.page.PageQuery;
import com.ruoyi.common.core.page.PageUtil;
import com.ruoyi.common.core.page.ResultEntity;
import com.ruoyi.system.domain.TDeviceFault;
import com.ruoyi.system.service.ITDeviceFaultService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

@Api(tags = "(客户端) 设备维护-故障记录")
@RestController
@RequestMapping("/client/device/fault")
public class TDeviceFaultController {
    @Autowired
    private ITDeviceFaultService deviceFaultService;

    @GetMapping("/list")
    @ApiOperation(value = "故障记录列表查询",response = TDeviceFault.class)
    public ResultEntity list(TDeviceFault params, PageQuery pageQuery){
        PageUtil.startPage(pageQuery);
        return ResultEntity.createSuccess(PageUtil.getPageList(deviceFaultService.list(new LambdaQueryWrapper<TDeviceFault>()
                        .eq(Objects.nonNull(params.getStatus()),TDeviceFault::getStatus,params.getStatus())
                        .orderByDesc(TDeviceFault::getFailTime))));
    }
}
